org 0x6000
use16

mov ax,0x0003
int 10h
mov dl,0x0f
mov ah,0x01
int 61h
mov ch,0x20
mov ah,0x01
int 0x10
.loop:
call reset
mov dl,0x00
call printf
call reset
mov dl,0xFA
call printf
call delay
;call reset
mov dl,0xF9
call printf
call delay
;call reset
mov dl,0x07
call printf
call delay
;call reset
;mov dl,0x09
;call printf
;call delay
;call reset
;mov dl,0x04
;call printf
;call delay
;call reset
mov dl,0x2A
call printf
call delay
;call reset
mov dl,0x0F
call printf
call delay
call reset
mov dl,0x00
call printf

mov ah,0x06
mov dl,0xFF
int 21h
cmp dl,0x0f
je .loop
mov cx,0x0506
mov ah,0x01
int 0x10
ret

reset:
mov ah,0x30
int 61h
mov cx,dx
.loop:
xor ah,ah
int 1ah
mov bl,dl
add dx,cx
mov al,bl
xor ah,ah
mul dx
mov dx,ax
cmp dh,25
jg .dhbig
.dhret:
cmp dl,0x50
jg .dlbig
.dlret:
cmp dh,2
jle .dhsmall
.dh2ret:
cmp dl,0x5
jle .dlsmall
.dl2ret:
cmp dl,5
jl .loop
cmp dl,70
jg .loop
cmp dh,2
jl .loop
mov ah,0x31
int 61h
ret
.dhbig:
sub dh,21
sub dl,6
cmp dh,25
jg .dhbig
jmp .dhret
.dlbig:
sub dl,63
cmp dl,80
jg .dlbig
sub dh,2
jmp .dlret

.dhsmall:
add dh,8
add dl,3
jmp .dh2ret
.dlsmall:
add dl,27
dec dh
jmp .dl2ret

printf:
mov al,dl
mov ah,0x09
xor bh,bh
mov cx,1
mov bl,0x0F
int 10h
ret

delay:
;mov ah,0x07
;int 21h
;ret
mov ah,0x09
int 61h
mov ah,0x09
int 61h
mov ah,0x09
int 61h
ret

times 512-($-$$) db 0